package com.ivncorp.evnproject.adapter;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.ivncorp.evnproject.R;
import com.ivncorp.evnproject.map.ObjectMap;

public class MapSearchAdapter  extends ArrayAdapter<ObjectMap> {

	private List<ObjectMap> listItems = new ArrayList<ObjectMap>();
	private Context context;

	public MapSearchAdapter(Context context, List<ObjectMap> objects) {
		super(context,R.layout.item_map_search, objects);
		this.context = context;
		this.listItems = objects;
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		
		LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		if (convertView == null){
			convertView = inflater.inflate(R.layout.item_map_search, null);
		}
		
		TextView txtName = (TextView) convertView.findViewById(R.id.txtMapsCotName);
		TextView txtCode = (TextView) convertView.findViewById(R.id.txtMapsCotCode);
		
		ObjectMap object = listItems.get(position);
		
		txtName.setText(object.getUploadTable().getName());
		txtCode.setText(object.getUploadTable().getName());
		
		return convertView;
	}

}
